# CMakeLists
# Author(s): xuming.Wong <xuming.Wong@gmail.com>

#-----------------------------------------------------------------------------
# 
MESSAGE(STATUS "Project PQBuilder...")

#-----------------------------------------------------------------------------
MESSAGE(STATUS "Finding Qt4...")
FIND_PACKAGE(Qt4 REQUIRED)

IF(QT4_FOUND)
	MESSAGE(STATUS "Qt4 find.")
	# Set src files
	FILE(GLOB SRC *.cpp Control/*.cpp GUI/*.cpp Core/*.cpp GUI/Terrain/*.cpp GUI/Asset/*.cpp GUI/Character/*.h GUI/Dialog/*.cpp GUI/Hierachy/*.cpp GUI/Material/*.h GUI/Object/*.cpp GUI/Property/*.cpp GUI/Scene/*.cpp )
	FILE(GLOB MOC_SRC *.h Control/*.h GUI/*.h GUI/Asset/*.h GUI/Terrain/*.h GUI/Character/*.h GUI/Dialog/*.h GUI/Hierachy/*.h GUI/Material/*.h GUI/Object/*.h GUI/Property/*.h GUI/Scene/*.h
	)
	
	FILE(GLOB QT_UI_FILES UI/*.ui)
	SOURCE_GROUP("UI" FILES ${QT_UI_FILES})
	
	QT4_WRAP_CPP(QT_MOC_OUT ${MOC_SRC})
	QT4_WRAP_UI(QT_UI_OUT ${QT_UI_FILES})
	
	# External includes
	SET(INC .
		./Core
		./Control
		./GUI
		./GUI/Asset
		./GUI/Character
		./GUI/Dialog
		./GUI/Hierachy
		./GUI/Material
		./GUI/Object
		./GUI/Property
		./GUI/Scene
		./GUI/Terrain

		
		${OGRE_INCLUDE_PATH}
		
		${LIBDIR}/mono/include
		${LIBDIR}/mono/include/glib-2.0
		${LIBDIR}/ois/include
		${LIBDIR}/cximage/include
		
		${PROJECT_SOURCE_DIR}/Dependencies/bullet/src
		${PROJECT_SOURCE_DIR}/Dependencies/hydrax/src
		${PROJECT_SOURCE_DIR}/Dependencies/stormlib
	
		${PROJECT_SOURCE_DIR}/Shared/PQHeaders
		${PROJECT_SOURCE_DIR}/Shared/PQCore
		${PROJECT_SOURCE_DIR}/Shared/PQEngine
		${PROJECT_SOURCE_DIR}/Shared/PQEngine/GFX
		${PROJECT_SOURCE_DIR}/Shared/PQEngine/GPK
		${PROJECT_SOURCE_DIR}/Shared/PQEngine/Mono
		${PROJECT_SOURCE_DIR}/Shared/PQEngine/Physics
		${PROJECT_SOURCE_DIR}/Shared/PQEngine/Terrain
		

		
	)
	#Include ui headers produced by qt:
	include_directories(${CMAKE_CURRENT_BINARY_DIR})
	SET(SRC ${SRC} ${QT_MOC_OUT} ${QT_UI_OUT})

	FILE(READ ${CMAKE_BINARY_DIR}/cmake_libs.txt OUT_LIBS)
	SET(LIB
		Imm32.lib
		qtmaind.lib
		QtCored4.lib
		QtGuid4.lib
		
		${LIBDIR}/mono/lib/mono.lib
		${LIBDIR}/cximage/lib/cximagecrtd.lib #hard link to debug library for i don't kown cmake well.
		${LIBDIR}/poco/lib/PocoFoundationd.lib
		
		${PQ3D_OGRE_LIBS}	
		${OUT_LIBS}
	)
	
	
	BUILD_EXE_Win32(PQBuilder "${SRC}" "${INC}")
	TARGET_LINK_LIBRARIES(PQBuilder ${LIB})
	
	SOURCE_GROUP("QT_MOC" FILES ${QT_MOC_OUT})
    SOURCE_GROUP("QT_UI" FILES ${QT_UI_OUT})
	
	set(INSTALL_DEBUG_FILES
		${LIBDIR}/qt/bin/QtCored4.dll
		${LIBDIR}/qt/bin/QtGuid4.dll
		
		${LIBDIR}/poco/bin/PocoFoundationd.dll
		${LIBDIR}/cximage/lib/cximagecrtd.dll
	)
	
	
	
	install(FILES ${INSTALL_DEBUG_FILES}
		DESTINATION ${EXECUTABLE_OUTPUT_PATH}/debug
	)

ENDIF()
